<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>小兔鲜儿 - 新鲜 惠民 快捷!</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="renderer" content="webkit">
  <link rel="shortcut icon" href="./favicon.ico">
  <link rel="stylesheet" href="./css/common.css">
  <link rel="stylesheet" href="./css/register.css">
  <link rel="stylesheet" href="https://at.alicdn.com/t/font_2143783_iq6z4ey5vu.css">
</head>

<body>
  <!-- 项部导航 -->
  <div class="xtx_topnav">
    <div class="wrapper">
      <!-- 顶部导航 -->
      <ul class="xtx_navs">
        <li>
          <a href="./login.html">请先登录</a>
        </li>
        <li>
          <a href="./register.html">免费注册</a>
        </li>
        <li>
          <a href="./center-order.html">我的订单</a>
        </li>
        <li>
          <a href="./center.html">会员中心</a>
        </li>
        <li>
          <a href="javascript:;">帮助中心</a>
        </li>
        <li>
          <a href="javascript:;">在线客服</a>
        </li>
        <li>
          <a href="javascript:;">
            <i class="mobile sprites"></i>
            手机版
          </a>
        </li>
      </ul>
    </div>
  </div>
  <!-- 头部 -->
  <div class="xtx_header">
    <div class="wrapper">
      <!-- 网站Logo -->
      <h1 class="xtx_logo"><a href="/">小兔鲜儿</a></h1>
      <!-- 主导航 -->
      <div class="xtx_navs">
        <ul class="clearfix">
          <li>
            <a href="./index.html">首页</a>
          </li>
          <li>
            <a href="./category01.html">生鲜</a>
          </li>
          <li>
            <a href="./category01.html">美食</a>
          </li>
          <li>
            <a href="./category01.html">餐厨</a>
          </li>
          <li>
            <a href="./category01.html">电器</a>
          </li>
          <li>
            <a href="./category01.html">居家</a>
          </li>
          <li>
            <a href="./category01.html">洗护</a>
          </li>
          <li>
            <a href="./category01.html">孕婴</a>
          </li>
          <li>
            <a href="./category01.html">服装</a>
          </li>
        </ul>
      </div>
      <!-- 站内搜索 -->
      <div class="xtx_search clearfix">
        <!-- 购物车 -->
        <a href="./cart-none.html" class="xtx_search_cart sprites">
          <i>2</i>
        </a>
        <!-- 搜索框 -->
        <div class="xtx_search_wrapper">
          <input type="text" placeholder="搜一搜" onclick="location.href='./search.html'">
        </div>
      </div>
    </div>
  </div>
  <div class="xtx-wrapper">
    <div class="container">
      <!-- 卡片 -->
      <div class="xtx-card">
        <h3>新用户注册</h3>
        <form class="xtx-form">
          <div data-prop="username" class="xtx-form-item">
            <span class="iconfont icon-zhanghao"></span>
            <input name="username" type="text" placeholder="设置用户名称">
            <span class="msg"></span>
          </div>
          <div data-prop="phone" class="xtx-form-item">
            <span class="iconfont icon-shouji"></span>
            <input name="phone" type="text" placeholder="输入手机号码  ">
            <span class="msg"></span>
          </div>
          <div data-prop="code" class="xtx-form-item">
            <span class="iconfont icon-zhibiaozhushibiaozhu"></span>
            <input name="code" type="text" placeholder="短信验证码">
            <span class="msg"></span>
            <a class="code" href="javascript:;">发送验证码</a>
          </div>
          <div data-prop="password" class="xtx-form-item">
            <span class="iconfont icon-suo"></span>
            <input name="password" type="password" placeholder="设置6至20位字母、数字和符号组合">
            <span class="msg"></span>
          </div>
          <div data-prop="confirm" class="xtx-form-item">
            <span class="iconfont icon-suo"></span>
            <input name="confirm" type="password" placeholder="请再次输入上面密码">
            <span class="msg"></span>
          </div>
          <div class="xtx-form-item pl50">
            <i class="iconfont icon-queren "></i>
            已阅读并同意<i>《用户服务协议》</i>
          </div>
          <div class="xtx-form-item">
            <button class="submit">下一步</button>
            <!-- <a class="submit" href="javascript:;">下一步</a> -->
          </div>
        </form>
      </div>
    </div>
  </div>
  <!-- 公共底部 -->
  <div class="xtx_footer clearfix">
    <div class="wrapper">
      <!-- 联系我们 -->
      <div class="contact clearfix">
        <dl>
          <dt>客户服务</dt>
          <dd class="chat">在线客服</dd>
          <dd class="feedback">问题反馈</dd>
        </dl>
        <dl>
          <dt>关注我们</dt>
          <dd class="weixin">公众号</dd>
          <dd class="weibo">微博</dd>
        </dl>
        <dl>
          <dt>下载APP</dt>
          <dd class="qrcode">
            <img src="./uploads/qrcode.jpg">
          </dd>
          <dd class="download">
            <span>扫描二维码</span>
            <span>立马下载APP</span>
            <a href="javascript:;">下载页面</a>
          </dd>
        </dl>
        <dl>
          <dt>服务热线</dt>
          <dd class="hotline">
            400-0000-000
            <small>周一至周日 8:00-18:00</small>
          </dd>
        </dl>
      </div>
    </div>
    <!-- 其它 -->
    <div class="extra">
      <div class="wrapper">
        <!-- 口号 -->
        <div class="slogan">
          <a href="javascript:;" class="price">价格亲民</a>
          <a href="javascript:;" class="express">物流快捷</a>
          <a href="javascript:;" class="quality">品质新鲜</a>
        </div>
        <!-- 版权信息 -->
        <div class="copyright">
          <p>
            <a href="javascript:;">关于我们</a>
            <a href="javascript:;">帮助中心</a>
            <a href="javascript:;">售后服务</a>
            <a href="javascript:;">配送与验收</a>
            <a href="javascript:;">商务合作</a>
            <a href="javascript:;">搜索推荐</a>
            <a href="javascript:;">友情链接</a>
          </p>
          <p>CopyRight &copy; 小兔鲜儿</p>
        </div>
      </div>
    </div>
  </div>
  <script>
    const username=document.querySelector('[name="username"]')
    //判断
    username.addEventListener('chenge',function(){
        //定义规则
        const reg =/^[a-zA-Z0-9_{6-16}$]/
        reg.test(this.value)
        const msg =username.nextElementSibling
        if(!reg.test(this.value)){
            msg.innerHTML='需要6-16位的字母或者数字'
        }else{
             msg.innerHTML=''
        }
    })


//    const reg = /^[a-zA-Z0-9_]{6,16}$/
//    const usernameInput =document.querySelector("input[name='username']")
//   //  const input= document.querySelector('input')
//   usernameInput.addEventListener('change',function(){
//     if(reg.test(this.value)){
//       usernameInput.nextElementSibling.innerHTML='输入正确'
//     }else{
//       usernameInput.nextElementSibling.innerHTML='只支持6到16位的由大小写字母和_组成'
//     }
//   })

  const reg1 = /^1[^12]\d{9}$/
   const phoneInput =document.querySelector("input[name='phone']")
  //  const input= document.querySelector('input')
  phoneInput.addEventListener('change',function(){
    if(reg1.test(this.value)){
      phoneInput.nextElementSibling.innerHTML='输入正确'
    }else{
      phoneInput.nextElementSibling.innerHTML='只支持由11位数字组成，请输入正确格式'
    }
  })
    
  const code =document.querySelector('.code')
  //开关
  let falg=true
  code.addEventListener('click',function(){
    if(falg===true){
        falg=false;
        let i =5
    code.innerText = `0${i}秒后重新获取`
    let n = setInterval(function(){
        i--
        code.innerText = `0${i}秒后重新获取`
        if(i===0){
            clearInterval(n)
            code.innerText = `重新获取`
            falg=true
        }
    },1000)
    }
  })
//   const reg2= /^\d{6}$/
//    const codeInput =document.querySelector("input[name='code']")
//   //  const input= document.querySelector('input')
//   codeInput.addEventListener('change',function(){
//     if(reg2.test(this.value)){
//       codeInput.nextElementSibling.innerHTML='验证成功'
//     }else{
//       codeInput.nextElementSibling.innerHTML='请输入正确的验证码'
//     }
//   })

//   // 验证码倒计时
//      const a= document.querySelector('.xtx-form-item a')
//      let i=5;
//      let n;
//      a.addEventListener('click',function(){
//     n= setInterval(function(){
//         if(i>0){
//           i--;
//           a.innerHTML=`发送验证码(${i})`
//         }else{
//           clearInterval(n)
//           a.innerHTML='验证通过'
//         }
//       },1000)
//      })
     
const  password= document.querySelector('[name="password"]')
password.addEventListener('chenge',function(){
    const reg = /^[a-zA-Z0-9]$/
    reg.test(this.value)
    const msg=password.nextElementSibling
    if(!reg.test(this.value)){
        msg.innerHTML='输入错误'
    }else{
         msg.innerHTML=''
    }
})

//      const reg3= /^\w{6,20}$/
//    const pwdInput =document.querySelector("input[name='password']")
//   //  const input= document.querySelector('input')
//   pwdInput.addEventListener('change',function(){
//     if(reg3.test(this.value)){
//       pwdInput.nextElementSibling.innerHTML='输入正确'
//     }else{
//       pwdInput.nextElementSibling.innerHTML='请输入正确格式'
//     }
//   })
const confirms = document.querySelector('[name="confirm"]')
confirms.addEventListener('chenge',function(){
    // const reg = /^[a-zA-Z0-9]$/
    reg.test(this.value)
    const msg=confirm.nextElementSibling
    if(this.value!=password.value){
        msg.innerHTML='输入密码不一致'
    }else{
         msg.innerHTML=''
    }
})

//   const reg4= /^\w{6,20}$/
//    const confirmInput =document.querySelector("input[name='confirm']")
//   //  const input= document.querySelector('input')
//   confirmInput.addEventListener('change',function(){
//     if(reg3.test(this.value)){
//       confirmInput.nextElementSibling.innerHTML='输入正确'
//     }else{
//       confirmInput.nextElementSibling.innerHTML='密码不同，请重新输入'
//     }
//   })

const queren = document.querySelector('.icon-queren')
queren.addEventListener('click',function(){
    queren.classList.toggle('icon-queren2')
})




//判断
const form = document.querySelector('form')
form.addEventListener('submit',function(){
    if (queren.classList.contains('icon-queren2'))
    alert('没有勾选')
})
//   const item = document.querySelector('.xtx-form-item.pl50 .iconfont.icon-queren');
// item.addEventListener('click', function(e){
//   if(e.target.tagName === 'I' && e.target.classList.contains('icon-queren')){
//     e.target.classList.toggle('active'); 
//   }
// });
  </script>
  </body>

  </html>